<?php
/*
Primary Author: Derek Shue
Secondary: Alex Arey
Documentation: Cheng Yi
Updated: 12/10/2011
Module Description: The Course Associations module adds/finds/updates/deletes Course Associations from the database.
*/
class Application_Model_DbTable_CourseAssociations extends Zend_Db_Table_Abstract
{

    protected $_name = 'COURSEASSOCIATIONS';

public function getCourseAssociation($where)
    {
        $row = $this->fetchRow($where);
        if (!$row) {
            return null;
        }
        return $row->toArray();
    }

    public function addCourseAssociation($rid, $cid,$numpositions, $term)
    {
        $data = array(
            'RID'=> $rid,
			'CID'=> $cid,
			'NUMPOSITIONS'=> $numpositions,
			'TERM' => $term,
        );
		print_r($data);
        $this->insert($data);
    }

    public function updateCourseAssociation($rid,$cid,$numpositions, $term)
    {
        $data = array(
			'NUMPOSITIONS'=> $numpositions,
			'TERM' => $term,
			
		);
        $this->update($data, 'RID = '. $rid . " AND CID = " . $cid);
    }

    public function deleteCourseAssociation($rid)
    {
        $this->delete('RID =' . (int)$rid);
    }
    public function existsCourseAssociation($rid,$cid){
    	return $this->getCourseAssociation('RID = '.$rid.' AND CID = '.$cid)!=null;
    }



}























































































































































